<?php

class Ext_Oauth_Login_ShowForm_Adapter
{
    private $_adapter;

    public function __construct()
    {
        if(!isset($this->_adapter))
        {
            $front = Zend_Controller_Front::getInstance();
            $bootstrap = $front->getParam('bootstrap');
            $options = $bootstrap->getApplication()->getOptions();

            $classname = "Ext_Oauth_Login_ShowForm_Adapter_".ucfirst($options['auth']['adapter']['base']);
            if(!class_exists( $classname )){
                require_once 'Ext/Oauth/Login/ShowForm/Exception.php';
                throw new Ext_Oauth_Login_ShowForm_Exception("Oauth show form adapter '".$classname."' is not exists.");
            }
            
            $this->_adapter = new $classname();
        }
    }
    
    public function showLoginForm(Ext_Oauth_Login_Result $oauth)
    {
        return $this->_adapter->showLoginForm($oauth);
    }
    
    public function showRegisterForm(Ext_Oauth_Login_Result $oauth)
    {
        return $this->_adapter->showRegisterForm($oauth);
    }
}
